package com.xinqing.bigdata.flink.table;


import com.xinqing.bigdata.flink.table.model.Student;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.Schema;
import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
import org.apache.flink.types.Row;

/**
 * @Author:CHQ
 * @Date:2021/5/31 14:33
 * @Description
 */
public class FromDataStream {
    public static void main(String args[]) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        StreamTableEnvironment tableEnvironment = StreamTableEnvironment.create(env);

        //tableEnvironment.fromDataStream(env.fromElements(Row.of("chq", 22), Row.of("jay", 45))).as("name", "age").printSchema();

        tableEnvironment.fromDataStream(env.fromElements(new Student("chq", 22),new Student("jay", 45)),
                Schema.newBuilder()
                        .column("name", "STRING")
                        .column("age", "INT")
                        .build()).printSchema();

        env.execute();

    }


}

